package com.aoyama.learnmvc.spring;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.stereotype.Component;

/**
 * @author ：qs
 * @date ：Created in 2022/7/5
 * @description：
 * @modified By：
 */
@Component
public class Person implements ApplicationContextAware, MessageSourceAware {

    ApplicationContext context;  //我们不用@Autowired也可以要到ioc容器
    MessageSource messageSource;

    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public Person(){
        System.out.println("person创建....");  //pos_1
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //利用回调机制，把ioc容器传入
        this.context = applicationContext;  //pos_2
    }

    @Override
    public void setMessageSource(MessageSource messageSource) {
        this.messageSource = messageSource;
    }
}
